import request from "../../../../utils/request";

/** 获取规则列表 GET /api/rule */
export async function rule(params: {
  // query
  /** 当前的页码 */
  current?: number;
  /** 页面的容量 */
  pageSize?: number;
}, options?: { [key: string]: any }) {
  const res = await request('/role', {
    params,
    method: 'GET',
    ...(options || {}),
  });
  //console.log(res)
  return {
    data: res.data.records
  }
}

export async function updateRule(data: { [key: string]: any }, options?: { [key: string]: any }) {
  //console.log(data)
  return request('/role', {
    data: {
      ...data,
      updataTime: new Date().getTime()
    },
    method: 'PUT',
    ...(options || {}),
  });
}

export async function addRule(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request('/role', {
    data: {
      ...data,
      createTime: new Date().getTime()
    },
    method: 'POST',
    ...(options || {}),
  });
}

export async function removeRule(data: { key: number[] }, options?: { [key: string]: any }) {
  return request('/role', {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}